package com.yearno.kotlinbaseframe

import android.content.pm.ActivityInfo
import android.content.res.Configuration
import android.os.Bundle
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import androidx.viewpager.widget.ViewPager
import com.google.android.material.floatingactionbutton.FloatingActionButton
import com.google.android.material.snackbar.Snackbar
import com.google.android.material.tabs.TabLayout
import com.yearno.baseframe.base.BaseActivity
import com.yearno.kotlinbaseframe.databinding.ActivityMain0Binding
import com.yearno.kotlinbaseframe.databinding.ActivityMainBinding
import com.yearno.kotlinbaseframe.ui.TestHoriDialog
import com.yearno.kotlinbaseframe.ui.main.SectionsPagerAdapter

class MainActivity : BaseActivity<ActivityMain0Binding>() {

    override fun getVB() = ActivityMain0Binding.inflate(layoutInflater, baseBinding?.root, true)

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val sectionsPagerAdapter = SectionsPagerAdapter(this, supportFragmentManager)
        viewBinding?.viewPager?.adapter = sectionsPagerAdapter
        viewBinding?.tabs?.setupWithViewPager(viewBinding?.viewPager)
        viewBinding?.fab?.setOnClickListener { view ->
//            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
//                    .setAction("Action", null).show()
            TestHoriDialog().show(supportFragmentManager,"TestHori")
        }
        viewBinding?.fab0?.setOnClickListener {
            if(this.resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT){
                requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE //横屏
            } else {
                requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT //竖屏
            }
        }

    }

}